<?php
namespace Home\Model;
use Think\Model;

/**
* 
*/
class UserCardModel extends Model
{
    function get_usercard($type_id,$user_id,$is_status = 1)
    {
        //is_status有效券 == 1 已使用 == 2 已失效 == 3
        $field = array(
                'u.type_id'   => $type_id,
                'u.user_id'   => $user_id,
                'u.is_status' => $is_status,
                );

        $result = $this->field('u.ucrd_id, c.card_name,c.card_img,c.start_time,c.end_time,c.card_time,c.card_address,c.card_details,c.card_rule,c.card_integral')
                  ->where($field)->table('am_user_card as u')
                  ->join('left join am_card_list as c on c.card_id=u.card_id')
                  ->order('u.ucrd_id desc')
                  //->fetchSql(true)
                  ->select();

        return $result;
    }
}